home *** CD-ROM | disk | FTP | other *** search
Text File | 1994-12-13 | 2.0 KB | 57 lines | [TEXT/ttxt] |
- language: infix-dylan
- module: Online-Insultant
-
- /* Copyright (C) 1994, Apple Computer, Inc. All rights reserved. */
-
- /* This is the "main program" for the application
- You can do main() in the Dylan Listener, or use
- it as the startup function and Create Application
- */
-
- // Minimum heap size is 850K, at 800K it will run into the Toolbox bug
- // that _NewWindow calls _NewPtr without checking whether it failed!
- // More recently, I saw System Error 25 at 800K, might be the same bug
- // Of course it will run in less memory if you don't have the
- // Text to Speech system extension.
-
- // For become-front-application
- define interface
- #include "Events.h",
- import: {"WaitNextEvent", "EventRecord"},
- type: {"RgnHandle" => <machine-pointer>};
- // Don't import slot accessors for EventRecord
- struct "EventRecord", import: {};
- end interface;
-
- // For become-front-application
- define interface
- #include "Processes.h",
- import: {"GetFrontProcess", "SetFrontProcess",
- "ProcessSerialNumber", "GetCurrentProcess"};
- end interface;
-
- define constant become-front-application = method()
- with-stack-structure(this-process(<ProcessSerialNumber>),
- begin
- with-stack-structure(dummy-event(<EventRecord>),
- begin
- // Bring this process to the front so the user can see the window
- GetCurrentProcess(this-process);
- let err = SetFrontProcess(this-process);
- if (err ~= 0) error("SetFrontProcess error %D", err); end if;
- // SetFrontProcess doesn't work until the next WaitNextEvent
- WaitNextEvent(0, dummy-event, 3, $null-machine-pointer);
- end)
- end)
- end method;
-
- define constant main = method()
- // When running tethered, bring the runtime application to the front
- unless (*stand-alone-p*)
- become-front-application();
- end unless;
- // Put up an insulting alert
- offer-random-insult();
- // next line should be redundant, actually, ExitToShell is supposed to do it
- await-speech-done();
- end method;